package com.aaa.service.impl;

import com.aaa.dao.FreturnsMapper;
import com.aaa.entity.Freturns;
import com.aaa.service.FreturnsServiceDao;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service
public class FreturnsServiceImpl extends ServiceImpl<FreturnsMapper, Freturns> implements FreturnsServiceDao {
    @Resource
    FreturnsMapper mapper;
    @Resource
    FreturnsServiceDao dao;
    @Override
    public List<Freturns> selectall(Integer fuser) {
        return mapper.selectall(fuser);
    }

    @Override
    public Integer fadd(Integer forder, String kuaidi, Integer parcelid, Integer fuser, Date returntime, String remark)throws ParseException {
        Date date=new Date();
        SimpleDateFormat sfd=new SimpleDateFormat();
        String now = sfd.format(date);
        Date date1=sfd.parse(now);
        returntime=date1;
        return mapper.fadd(forder,kuaidi,parcelid,fuser,returntime,remark);
    }

    public boolean upadd(Freturns freturns)throws ParseException {
        Date date=new Date();
        SimpleDateFormat sfd=new SimpleDateFormat();
        String now = sfd.format(date);
        Date date1=sfd.parse(now);
        freturns.setReturntime(date1);
        boolean add=dao.saveOrUpdate(freturns);
        return add;
    }//添加或修改
    public Integer del(Integer id){
        int del=mapper.deleteById(id);
        return del;
    }//删除
}
